
package ch.hearc.coursJava.IO.RMI.exemple0.pcA.use;

import java.rmi.Remote;
import java.rmi.RemoteException;

import ch.hearc.coursJava.IO.RMI.exemple0.pcA.moo.Horloge;
import ch.hearc.coursJava.IO.RMI.exemple0.pcB.moo.Secret;
import ch.hearc.coursJava.IO.RMI.exemple0.pcB.moo.Secret_I;

import com.bilat.tools.reseau.rmi.RmiTools;

public class UsePcA
	{

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	public static void main(String[] args)
		{
		main();
		}

	public static void main()
		{
		serveur();
		client();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	private static void client()
		{
		Remote remote = RmiTools.connectionRemoteObjectBloquant(Secret.IP.getHostName(), Secret.ID, Secret.PORT);
		Secret_I secret = (Secret_I)remote;

		try
			{
			System.out.println(secret.getSecret());
			}
		catch (RemoteException e)
			{
			e.printStackTrace();
			}
		}

	private static void serveur()
		{
		try
			{
			Horloge horloge = new Horloge();
			}
		catch (RemoteException e)
			{
			e.printStackTrace();
			}
		}
	}
